package com.sptus.system.domain.alarm;

import java.util.concurrent.ConcurrentHashMap;
import java.util.Map;

public enum FaultEnum {
    FAULT_01("01", "BUS exceed the upper limit", "BUS高压"),
    FAULT_02("02", "BUS dropp to the lower limit", "BUS低压"),
    FAULT_03("03", "BUS soft start circuit timeout", "BUS软启动超时"),
    FAULT_04("04", "Inverter voltage soft start timeout", "逆变软启动超时"),
    FAULT_05("05", "Inverter current exceed the upper limit", "逆变过流"),
    FAULT_06("06", "Temperature over", "过温"),
    FAULT_07("07", "Inverter relay work abnormal", "继电器故障"),
    FAULT_08("08", "Current sample abnormal when inverter doesn't work", "机器并工作时，电流采样异常"),
    FAULT_09("09", "Solar input voltage exceed upper limit", "Solar输入电压过高"),
    FAULT_10("10", "SPS power voltage abnormal", "辅助电源电压异常"),
    FAULT_11("11", "Solar input current exceed upper limit", "Solar输入电流过高"),
    FAULT_12("12", "Leakage current exceed permit range", "漏电流超过允许范围"),
    FAULT_13("13", "Solar insulation resistance too low", "Solar对地绝缘阻抗过低"),
    FAULT_14("14", "Inverter DC current exceed permit range when feed power", "并网时，逆变电流直流分量超过允许范围"),
    FAULT_15("15", "The AC input voltage or frequency has been detected different between master CPU and slave CPU", "主从CPU对AC输入电压或频率侦测值相差较大"),
    FAULT_16("16", "Leakage current detect circuit abnormal when inverter doesn't work", "机器未工作时，漏电流检测电路异常"),
    FAULT_17("17", "Comminication loss between master CPU and slave CPU", "主从CPU通信丢失"),
    FAULT_18("18", "Comminicate data discordant between master CPU and slave CPU", "主从CPU通信协议不匹配"),
    FAULT_19("19", "AC input ground wire loss", "地线未接"),
    FAULT_20("20", "", ""),
    FAULT_21("21", "", ""),
    FAULT_22("22", "Battery voltage exceed upper limit", "电池电压过高"),
    FAULT_23("23", "Over load", "过载"),
    FAULT_24("24", "S phase Inverter current exceed the upper limit", "S相逆变过流"),
    FAULT_25("25", "T phase Inverter current exceed the upper limit", "T相逆变过流"),
    FAULT_26("26", "AC output short", "输出短接"),
    FAULT_27("27", "Fan lock", "风扇堵转"),
    FAULT_28("28", "", ""),
    FAULT_29("29", "inverter Current sample abnormal when inverter doesn't work", "机器并工作时，逆变电流采样异常"),
    FAULT_30("30", "S phase Inverter DC current exceed permit range when feed power", "并网时，S相逆变电流直流分量超过允许范围"),
    FAULT_31("31", "T phase Inverter DC current exceed permit range when feed power", "并网时，T相逆变电流直流分量超过允许范围"),
    FAULT_32("32", "Battery DC-DC current over", "电池DC-DC电流过高"),
    FAULT_33("33", "AC output voltage too low", "输出电压过低"),
    FAULT_34("34", "AC output voltage too high", "输出电压过高"),
    FAULT_35("35", "Control board wiring error", "控制板接线异常"),
    FAULT_36("36", "AC circuit voltage sample error", "AC电路电压采样差异较大"),
    FAULT_37("37", "AC N wire current over", "市电N线过流"),
    FAULT_38("38", "", ""),
    FAULT_39("39", "S phase AC output voltage too low", "S相输出电压过低"),
    FAULT_40("40", "T phase AC output voltage too low", "T相输出电压过低"),
    FAULT_41("41", "S phase AC output voltage too high", "S相输出电压过高"),
    FAULT_42("42", "T phase AC output voltage too high", "T相输出电压过高"),
    FAULT_43("43", "", ""),
    FAULT_44("44", "", ""),
    FAULT_45("45", "", ""),
    FAULT_46("46", "", ""),
    FAULT_47("47", "", ""),
    FAULT_48("48", "", ""),
    FAULT_49("49", "", ""),
    FAULT_50("50", "Relay version error", "继电器版本错误"),
    FAULT_51("51", "The external battery is overheating", "外接电池过温"),
    FAULT_52("52", "Sloar1 over temperature", "Sloar1过温"),
    FAULT_53("53", "Sloar2 over temperature", "Sloar2过温"),
    FAULT_54("54", "Nbat over temperature", "Nbat过温"),
    FAULT_55("55", "R-phase inverter over-temperature", "R相逆变过温"),
    FAULT_56("56", "S-phase inverter over-temperature", "S相逆变过温"),
    FAULT_57("57", "T-phase inverter over-temperature", "T相逆变过温"),
    FAULT_58("58", "PDCDC over temperature", "PDCDC过温"),
    FAULT_59("59", "", ""),
    FAULT_60("60", "Negative power detected", "负功保护"),
    FAULT_61("61", "Driver signal lost from relay board", "Relay board的驱动信号丢失"),
    FAULT_62("62", "Communication lost between main board and relay board", "主板与relay board通讯丢失"),
    FAULT_63("63", "Versions are different between main board and relay board", "主板与relay board版本不匹配"),
    FAULT_64("64", "", ""),
    FAULT_65("65", "", ""),
    FAULT_66("66", "", ""),
    FAULT_67("67", "", ""),
    FAULT_68("68", "", ""),
    FAULT_69("69", "", ""),
    FAULT_70("70", "", ""),
    FAULT_71("71", "parellel version is incompatible", "并联版本不兼容"),
    FAULT_72("72", "O/P current detection abnormal", "输出电流侦测异常"),
    FAULT_73("73", "", ""),
    FAULT_74("74", "", ""),
    FAULT_75("75", "", ""),
    FAULT_76("76", "", ""),
    FAULT_77("77", "", ""),
    FAULT_78("78", "", ""),
    FAULT_79("79", "", ""),
    FAULT_80("80", "CAN lost", "CAN丢失"),
    FAULT_81("81", "HOST lost", "主机线丢失"),
    FAULT_82("82", "SYN lost", "同步信号丢失"),
    FAULT_83("83", "", ""),
    FAULT_84("84", "", ""),
    FAULT_85("85", "", ""),
    FAULT_86("86", "", ""),
    FAULT_87("87", "", ""),
    FAULT_88("88", "BUS Balances overcurrent", "BUS平衡过流");

    private final String code;
    private final String english;
    private final String chinese;
    
    // 使用ConcurrentHashMap来缓存故障代码到枚举值的映射
    private static final Map<String, FaultEnum> CODE_MAP = new ConcurrentHashMap<>();
    
    static {
        // 初始化时将所有枚举值放入Map中
        for (FaultEnum fault : values()) {
            CODE_MAP.put(fault.getCode(), fault);
        }
    }

    FaultEnum(String code, String english, String chinese) {
        this.code = code;
        this.english = english;
        this.chinese = chinese;
    }

    public String getCode() {
        return code;
    }

    public String getEnglish() {
        return english;
    }

    public String getChinese() {
        return chinese;
    }

    public static FaultEnum getByCode(String code) {
        return CODE_MAP.get(code);
    }
} 